<?php
	
	class stat_product_dayControl extends skymvc{
		public $sw; 
		public $k;
		public function __construct(){
			
			parent::__construct();
		}
		
		public function onDefault(){
	 
			$k='koudai';
			 
			$where= " k='$k' AND shopid=".SHOPID;
			$start=get('per_page','i');
			$limit=96;
			$url=APPKOUDAI."?m=stat_product_day&k=".$k;
		 
			$kday=get('kday','h');
			if(!$kday){
				$kday=date("Ymd");
			}
			$where.=" AND kday='".$kday."'";
			$url.="&kday=".$kday;
		 
			$option=array(
				"where"=>$where,
				"start"=>$start,
				"limit"=>$limit,			
				"order"=>" ordernum DESC",
			);
			$rscount=true;
			$data=M("stat_product_day")->select($option,$rscount);
			if($data){
				
				foreach($data as $v){
					$productids[]=$v['productid'];
				}
				if($k=='shop'){
					$products=M("shop_product")->getListByIds($productids);
				}else{
					$products=M("product")->getListByIds($productids);
				}
				
				
				foreach($data as $k=>$v){
					$productids[]=$v['productids'];
					$v['title']=$products[$v['productid']]['title'];
					$data[$k]=$v;
				}					
				 
				
			}
				 
			 
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->assign(array(
				"list"=>$data,
				"rscount"=>$rscount,
				"pagelist"=>$pagelist,
				"kday"=>$kday,
				"field"=>$field,
				"total_money"=>$total_money
			));
			$this->smarty->display("stat_product_day/index.html");
		}
		
		 
		
	}